Skip to content

RegionEdit

Base classes

Name Children Inherits
BaseRectEdit
prettyqt.custom_widgets.editors.rectedit

⋔ Inheritance diagram

graph TD
  3943219547["custom_widgets.RegionEdit"]
  940209780["custom_widgets.BaseRectEdit"]
  3664736470["widgets.Widget"]
  829357528["widgets.WidgetMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  625385617["gui.PaintDeviceMixin"]
  3620195106["QtWidgets.QWidget"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  673956333["QtGui.QPaintDevice"]
  940209780 --> 3943219547
  3664736470 --> 940209780
  829357528 --> 3664736470
  3227531497 --> 829357528
  2751680898 --> 3227531497
  625385617 --> 829357528
  2751680898 --> 625385617
  2751680898 --> 829357528
  3620195106 --> 3664736470
  3984060476 --> 3620195106
  37984305 --> 3984060476
  2751680898 --> 37984305
  673956333 --> 3620195106
  37984305 --> 673956333

🛈 DocStrings

Bases: BaseRectEdit

Source code in prettyqt/custom_widgets/editors/rectedit.py
class RegionEdit(BaseRectEdit):
    Widget = widgets.SpinBox
    value_changed = core.Signal(gui.QRegion)
    Typ = gui.QRegion
    spinbox_x: widgets.SpinBox
    spinbox_y: widgets.SpinBox
    spinbox_width: widgets.SpinBox
    spinbox_height: widgets.SpinBox

    def get_value(self) -> gui.Region:
        return gui.Region(
            self.spinbox_x.value(),
            self.spinbox_y.value(),
            self.spinbox_width.value(),
            self.spinbox_height.value(),
        )

    def set_value(self, value: gui.QRegion | tuple[int, int, int, int]):
        if isinstance(value, tuple):
            value = gui.Region(*value)
        self._value = value
        bounding_rect = value.boundingRect()
        self.spinbox_x.set_value(bounding_rect.x())
        self.spinbox_y.set_value(bounding_rect.y())
        self.spinbox_width.set_value(bounding_rect.width())
        self.spinbox_height.set_value(bounding_rect.height())

    value = core.Property(
        gui.Region,
        get_value,
        set_value,
        user=True,
        doc="Current value",
    )

:fa-brands-github: Show source on GitHub